package edu.isquen.webservice.weather;

import java.net.URL;

public class WeatherUtil {
	public static WeatherWebServiceLocator weatherSLocator=null;
	public static WeatherWSLocator weatherWSLocator=null;
	static String weatherSLocatorURL="http://www.webxml.com.cn/WebServices/WeatherWebService.asmx?wsdl";
	static String weatherWSLocatorURL="http://webservice.webxml.com.cn/WebServices/WeatherWS.asmx?wsdl";
	
	public static WeatherWebServiceLocator getWeatherWebServiceLocator(){
		if(weatherSLocator==null){
			weatherSLocator=new WeatherWebServiceLocator();
		}
		return weatherSLocator;
	}
	
	public static WeatherWSLocator getWeatherWLocator(){
		if(weatherWSLocator==null){
			weatherWSLocator=new WeatherWSLocator();
		}
		return weatherWSLocator;
	}
	
	public static WeatherWebServiceSoap getWeatherWebService(){
		WeatherWebServiceSoap weatherWebService=null;
		try {
			weatherWebService = (WeatherWebServiceSoap) getWeatherWebServiceLocator().getWeatherWebServiceSoap(new URL(weatherSLocatorURL));
		} catch (Exception e) {
			e.printStackTrace();
		}
		return weatherWebService;
	}
	
	public static WeatherWSSoap getWeatherWS(){
		WeatherWSSoap weatherWebService=null;
		try {
			weatherWebService = (WeatherWSSoap) getWeatherWLocator().getWeatherWSSoap(new URL(weatherWSLocatorURL));
		} catch (Exception e) {
			e.printStackTrace();
		}
		return weatherWebService;
	}
	
	public static void main(String[] agrs){
		try {
//			agrs=getWeatherWebService().getWeatherbyCityNamePro("广州", "ecf97f5bd49a41efac29ddcff0f91795 ");
//			System.out.println(agrs[0]);
//			System.out.println(agrs[1]);
		} catch (Exception e) {
		}
	}
}
